import * as Vue from 'vue'
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import tableEdit from 'chen-table-edit'
import App from './App.vue'
import router from './router'
import store from './store'
import global from '@/utils/global'

import 'element-plus/dist/index.css'
import '@/assets/style/global.scss'
import 'chen-table-edit/dist/style.css'
// import './assets/index.umd.js'

window.Vue = Vue

const createScript = (url) => new Promise((resolve) => {
    const DOM = document.createElement('script')
    DOM.src = url
    const dom = Array.from(document.querySelectorAll('script')).find((dom) => dom.src === DOM.src)
    if (dom) {
        resolve()
        return
    }
    DOM.type = 'text/javascript'
    DOM.onload = () => {
        resolve()
    }
    document.body.appendChild(DOM)
})
console.log()

createScript('//unpkg.com/element-plus')

createApp(App)
    .use(ElementPlus, { locale: zhCn })
    .use(router)
    .use(store)
    .use(global)
    .use(tableEdit)
    .mount('#app')
